// https://www.cnblogs.com/qcloud1001/p/10491411.html

// https://www.jianshu.com/p/487ed4435647

// const proxy = new Proxy(fakeWindow, {

// })


class ProxySandbox {
    constructor() {
        const rawWindow = window;
        const fakeWindow = {}
        const proxy = new Proxy(fakeWindow, {
            set(target, p, value) { target[p] = value; return true },
            get(target, p) { return target[p] || rawWindow[p]; }
        });
        this.proxy = proxy
    }
}
let sandbox1 = new ProxySandbox();
let sandbox2 = new ProxySandbox();
window.a = 1;
((window) => { window.a = 'hello'; console.log(window.a) })(sandbox1.proxy);
((window) => { window.a = 'world'; console.log(window.a) })(sandbox2.proxy);